﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PdfContentSelect
{
       
    public partial class QueryResult : Form
    {
        List<PDFResult> lists = new List<PDFResult>();
        public QueryResult(List<PDFResult> a)
        {
            InitializeComponent();
            lists = a;
            listView1.BeginUpdate();
            List<PDFResult> tmp = new List<PDFResult>();
            foreach (PDFResult item in lists)
            {
                if (item.IsOpen==true)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = item.FilePath;
                    lvi.SubItems.Add(item.IsOpen.ToString());
                    listView1.Items.Add(lvi);
                }
                else
                {
                    tmp.Add(item);
                }
            }

            foreach (PDFResult item in tmp)
            {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = item.FilePath;
                    lvi.SubItems.Add(item.IsOpen.ToString());
                    listView1.Items.Add(lvi);
            }

            tmp.Clear();
            listView1.EndUpdate();
        }

        public QueryResult()
        {
            InitializeComponent();
        }
        private void QueryResult_FormClosing(object sender, FormClosingEventArgs e)
        {
            listView1.Clear();
            lists.Clear();
        }

        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string path = listView1.SelectedItems[0].Text;
            System.Diagnostics.Process.Start(path); //打开此文件。
        }
    }
}
